import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { View, StyleSheet } from 'react-native'
import CustomStatusBar from './CustomStatusBar'
import CustomNavigationHeader from './CustomNavigationHeader'
import { NAVIGATIONBAR_HEIGHT } from 'src/utils/ScreenUtil'

export default class CustomHeader extends PureComponent {
  static propTypes = {
    goBack: PropTypes.func,
    barStyle: PropTypes.string,
    headerBg: PropTypes.string,
    children: PropTypes.node
  }

  render () {
    const { barStyle, headerBg, goBack, children } = this.props || {}
    return (
      <View
        style={[styles.container, headerBg && { backgroundColor: headerBg }]}
      >
        <CustomStatusBar barStyle={barStyle} headerBg={headerBg} />
        <CustomNavigationHeader goBack={goBack}>
          {children}
        </CustomNavigationHeader>
      </View>
    )
  }
}
const styles = StyleSheet.create({
  container: {
    position: 'absolute',
    top: 0,
    left: 0,
    width: '100%',
    height: NAVIGATIONBAR_HEIGHT,
    zIndex: 100,
    backgroundColor: '#ffffff'
  }
})
